import { CellRenderer } from "../../../../fl/controls/listClasses/CellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SFriendBlessInfo } from "../../../../Message/Public/SFriendBlessInfo";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
//class SendBlessListCellRenderer
    
    export  class SendBlessListCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.mouseEnabled = true;
            this.mouseChildren = true;
            this.initStyle();
            this.createChildren();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._nameLabel = ObjCreate.createLabel("", 0, 8, 120, 20, flash.text.TextFormatAlign.CENTER, this, false, 11661311);
            this._nameLabel.drawNow();
            this._sexLabel = ObjCreate.createLabel("", 120, 8, 55, 20, flash.text.TextFormatAlign.CENTER, this, false, 11661311);
            this._sexLabel.drawNow();
            this._levelLabel = ObjCreate.createLabel("", 175, 8, 55, 20, flash.text.TextFormatAlign.CENTER, this, false, 11661311);
            this._levelLabel.drawNow();
            this._campLabel = ObjCreate.createLabel("", 230, 8, 55, 20, flash.text.TextFormatAlign.CENTER, this, false, 11661311);
            this._campLabel.drawNow();
            this._optBtn = ObjCreate.createGButton(Language.getString(69442), 300, 8, 49, 22, this);
            this._optBtn.drawNow();
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.friendbless_SendBless, data));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            super.data = arg1;
            if (arg1) 
            {
                loc1 = arg1 as SFriendBlessInfo;
                loc2 = ColorConfig.instance.getCampColor(loc1.fromPlayerCamp).color;
                this._nameLabel.htmlText = HTMLUtil.addColor(loc1.fromPlayerName, loc2);
                this._sexLabel.htmlText = HTMLUtil.addColor(GameDefConfig.instance.getSex(loc1.fromPlayerSex).name, loc2);
                this._levelLabel.htmlText = HTMLUtil.addColor("" + loc1.blessLevel, loc2);
                this._campLabel.htmlText = HTMLUtil.addColor(GameDefConfig.instance.getECamp(loc1.fromPlayerCamp), loc2);
            }
            return;
        }

        /* internal */ /* var */_nameLabel: GLabel;

        /* internal */ /* var */_sexLabel: GLabel;

        /* internal */ /* var */_levelLabel: GLabel;

        /* internal */ /* var */_campLabel: GLabel;

        /* internal */ /* var */_optBtn: GButton;
    }
